package net.caixiaomi.info.adapter;

import android.support.annotation.LayoutRes;
import android.text.TextUtils;

import net.caixiaomi.info.R;
import net.caixiaomi.info.base.quickadapter.BaseQuickAdapter;
import net.caixiaomi.info.base.quickadapter.BaseViewHolder;
import net.caixiaomi.info.model.WithdrawdetailItem;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 提现详情
 */

public class WithdrawDetailAdapter extends BaseQuickAdapter<WithdrawdetailItem, BaseViewHolder> {

    public WithdrawDetailAdapter(@LayoutRes int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, WithdrawdetailItem item) {
        int adapterPosition = helper.getAdapterPosition();
        helper.setVisible(R.id.up, adapterPosition - getFooterLayoutCount() != 0);
        helper.setVisible(R.id.down, adapterPosition - getFooterLayoutCount() != getData().size() - 1);
        helper.setText(R.id.title, item.getLogName());
        if (!TextUtils.isEmpty(item.getLogTime())) {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String time = dateFormat.format(new Date(Long.valueOf(item.getLogTime())  * 1000));
            helper.setText(R.id.time, time);
        }
        helper.setGone(R.id.time, !TextUtils.isEmpty(item.getLogTime()));
        helper.getView(R.id.status).setSelected(!TextUtils.isEmpty(item.getLogTime()));
        //提现状态根据时间比较 是否为空
    }
}
